# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-pcre
_pkgname=pcre
pkgver=7.5.0
pkgrel=1
pkgdesc="OCaml bindings to the Perl Compatibility Regular Expressions (PCRE) library"
url="https://mmottl.github.io/pcre-ocaml"
arch="all !riscv64"  # limited by ocaml aport
license="LGPL-2.1-or-later-WITH-linking-exception"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="dune dune-configurator ocaml pcre-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mmottl/pcre-ocaml/releases/download/$pkgver/pcre-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
be60f13ddb6bbfe20e30ca5d92434d85e1d1371479e1e2c725588af83fcc9366ed0435021b6a800c20336ac521f2134c767420136438684656a44ac1f9924be4  ocaml-pcre-7.5.0.tar.bz2
"
